Extension of write anywhere file layout write allocation

ABSTRACT

A plurality of storage devices is organized into a physical volume called an aggregate, and the aggregate is organized into a global storage space, and a data block is resident on one of the storage devices of the plurality of storage devices. A plurality of virtual volumes is organized within the aggregate and the data block is allocated to a virtual volume. A physical volume block number (pvbn) is selected for the data block from a pvbn space of the aggregate, and virtual volume block number (vvbn) for the data block is selected from a vvbn space of the selected vvol. Both the selected pvbn and the selected vvbn are inserted in a parent block as block pointers to point to the allocated data block on the storage device.

CROSS-REFERENCE TO RELATED APPLICATION

The present application is a continuation of commonly assigned U.S.patent application Ser. No. 13/115,541 filed on May 25, 2011, now issuedas U.S. Pat. No. ______ on ______; which is a divisional of commonlyassigned U.S. patent application Ser. No. 12/042,131, filed on Mar. 4,2008 now issued as U.S. Pat. No. 7,970,770 on Jun. 28, 2011, which is acontinuation of U.S. patent application Ser. No. 10/836,090, filed byJohn K. Edwards on Apr. 30, 2004 now issued as U.S. Pat. No. 7,430,571on Sep. 30, 2008.

Also the present application is related to commonly assigned U.S. patentapplication Ser. No. 10/836,817 titled, Extension of Write Anywhere FileSystem Layout, filed by John K. Edwards et al. on Apr. 30, 2004, nowissued as U.S. Pat. No. 7,409,494 on Aug. 5, 2008.

FIELD OF THE INVENTION

The present invention relates to file systems and, more specifically, towrite allocation in a write anywhere file system.

BACKGROUND OF THE INVENTION

A storage system typically comprises one or more storage devices intowhich information may be entered, and from which information may beobtained, as desired. The storage system includes a storage operatingsystem that functionally organizes the system by, inter alia, invokingstorage operations in support of a storage service implemented by thesystem. The storage system may be implemented in accordance with avariety of storage architectures including, but not limited to, anetwork-attached storage environment, a storage area network and a diskassembly directly attached to a client or host computer. The storagedevices are typically disk drives organized as a disk array, wherein theterm “disk” commonly describes a self-contained rotating magnetic mediastorage device. The term disk in this context is synonymous with harddisk drive (HDD) or direct access storage device (DASD).

Storage of information on the disk array is preferably implemented asone or more storage “volumes” of physical disks, defining an overalllogical arrangement of disk space. The disks within a volume aretypically organized as one or more groups, wherein

-   -   each group may be operated as a Redundant Array of Independent        (or Inexpensive) Disks (RAID). Most RAID implementations enhance        the reliability/integrity of data storage through the redundant        writing of data “stripes” across a given number of physical        disks in the RAID group, and the appropriate storing of        redundant information (parity) with respect to the striped data.        The physical disks of each RAID group may include disks        configured to store striped data (i.e., data disks) and disks        configured to store parity for the data (i.e., parity disks).        The parity may thereafter be retrieved to enable recovery of        data lost when a disk fails. The term “RAID” and its various        implementations are well-known and disclosed in A Case for        Redundant Arrays of Inexpensive Disks (RAID), by D. A.        Patterson, G. A. Gibson and R. H. Katz, Proceedings of the        International Conference on Management of Data (SIGMOD), June        1988.

The storage operating system of the storage system may implement ahigh-level module, such as a file system, to logically organize theinformation stored on the disks as a hierarchical structure ofdirectories, files and blocks. For example, each “on-disk” file may beimplemented as set of data structures, i.e., disk blocks, configured tostore information, such as the actual data for the file. These datablocks are organized within a volume block number (vbn) space that ismaintained by the file system. The file system may also assign each datablock in the file a corresponding “file offset” or file block number(fbn). The file system typically assigns sequences of fbns on a per-filebasis, whereas vbns are assigned over a larger volume address space. Thefile system organizes the data blocks within the vbn space as a “logicalvolume”; each logical volume may be, although is not necessarily,associated with its own file system. The file system typically consistsof a contiguous range of vbns from zero to n, for a file system of sizen−1 blocks.

A known type of file system is a write-anywhere file system that doesnot overwrite data on disks. If a data block is retrieved (read) fromdisk into a memory of the storage system and “dirtied” (i.e., updated ormodified) with new data, the data block is thereafter stored (written)to a new location on disk to optimize write performance. Awrite-anywhere file system may initially assume an optimal layout suchthat the data is substantially contiguously arranged on disks. Theoptimal disk layout results in efficient access operations, particularlyfor sequential read operations, directed to the disks. An example of awrite-anywhere file system that is configured to operate on a storagesystem is the Write Anywhere File Layout (WAFL™) file system availablefrom Network Appliance, Inc., Sunnyvale, Calif.

The storage operating system may further implement a storage module,such as a is RAID system, that manages the storage and retrieval of theinformation to and from the disks in accordance with input/output (I/O)operations. The RAID system is also responsible for parity operations inthe storage system. Note that the file system only “sees” the data diskswithin its vbn space; the parity disks are “hidden” from the file systemand, thus, are only visible to the RAID system. The RAID systemtypically organizes the RAID groups into one large “physical” disk(i.e., a physical volume), such that the disk blocks are concatenatedacross all disks of all RAID groups. The logical volume maintained bythe file system is then “disposed over” (spread over) the physicalvolume maintained by the RAID system.

The storage system may be configured to operate according to aclient/server model of information delivery to thereby allow manyclients to access the directories, files and blocks stored on thesystem. In this model, the client may comprise an application; such as adatabase application, executing on a computer that “connects” to thestorage system over a computer network, such as a point-to-point link,shared local area network, wide area network or virtual private networkimplemented over a public network, such as the Internet. Each client mayrequest the services of the file system by issuing file system protocolmessages (in the form of packets) to the storage system over thenetwork. By supporting a plurality of file system protocols, such as theconventional Common Internet File System (CIFS) and the Network FileSystem (NFS) protocols, the utility of the storage system is enhanced.

When accessing a block of a file in response to servicing a clientrequest, the file system specifies a vbn that is translated at the filesystem/RAID system boundary into a disk block number (dbn) location on aparticular disk (disk, dbn) within a RAID group of the physical volume.Each block in the vbn space and in the dbn space is typically fixed,e.g., 4k bytes (kB), in size; accordingly, there is typically aone-to-one mapping between the information stored on the disks in thedbn space and the information organized by the file system in the vbnspace. The (disk, dbn) location specified by the RAID system is furthertranslated by a disk driver system of the storage operating system intoa plurality of sectors (e.g., a 4 kB block with a RAID header translatesto 8 or 9 disk sectors of 512 is or 520 bytes) on the specified disk.

The requested block is then retrieved from disk and stored in a buffercache of the memory as part of a buffer tree of the file. The buffertree is an internal representation of blocks for a file stored in thebuffer cache and maintained by the file system. Broadly stated, thebuffer tree has an inode at the root (top-level) of the file. An inodeis a data structure used to store information, such as metadata, about afile, whereas the data blocks are structures used to store the actualdata for the file. The information contained in an inode may include,e.g., ownership of the file, access permission for the file, size of thefile, file type and references to locations on disk of the data blocksfor the file. The references to the locations of the file data areprovided by pointers, which may further reference indirect blocks that,in turn, reference the data blocks, depending upon the quantity of datain the file. Each pointer may be embodied as a vbn to facilitateefficiency among the file system and the RAID system when accessing thedata on disks.

The RAID system maintains information about the geometry of theunderlying physical disks (e.g., the number of blocks in each disk) inraid labels stored on the disks. The RAID system provides the diskgeometry information to the file system for use when creating andmaintaining the vbn-to-disk, dbn mappings used to perform writeallocation operations and to translate vbns to disk locations for readoperations. Block allocation data structures, such as an active map, asnapmap, a space map and a summary map, are data structures thatdescribe block usage within the file system, such as the write-anywherefile system. These mapping data structures are independent of thegeometry and are used by a write allocator of the file system asexisting infrastructure for the logical volume.

Specifically, the snapmap denotes a file including a bitmap associatedwith the vacancy of blocks of a snapshot. The write-anywhere file system(such as the WAFL file system) has the capability to generate a snapshotof its active file system. An “active file system” is a file system towhich data can be both written and read, or, more generally, an activestore that responds to both read and write I/O operations. It should benoted that “snapshot” is a trademark of Network Appliance, Inc. and isused for purposes of this patent to designate a persistent consistencypoint (CP) image. A persistent consistency point image (PCPI) is a spaceconservative, point-in-time read-only image of data accessible by namethat provides a consistent image of that data (such as a storage system)at some previous time. More particularly, a PCPI is a point-in-timerepresentation of a storage element, such as an active file system, fileor database, stored on a storage device (e.g., on disk) or otherpersistent memory and having a name or other identifier thatdistinguishes it from other PCPIs taken at other points in time. In thecase of the WAFL file system, a PCPI is always an active file systemimage that contains complete information about the file system,including all metadata. A PCPI can also include other information(metadata) about the active file system at the particular point in timefor which the image is taken. The terms “PCPI” and “snapshot” may beused interchangeably through out this patent without derogation ofNetwork Appliance's trademark rights.

The write-anywhere file system supports multiple snapshots that aregenerally created on a regular schedule. Each snapshot refers to a copyof the file system that diverges from the active file system over timeas the active file system is modified. In the case of the WAFL filesystem, the active file system diverges from the snapshots since thesnapshots stay in place as the active file system is written to new disklocations. Each snapshot is a restorable version of the storage element(e.g., the active file system) created at a predetermined point in timeand, as noted, is “read-only” accessible and “space-conservative”. Spaceconservative denotes that common parts of the storage element inmultiple snapshots share the same file system blocks. Only thedifferences among these various snapshots require extra storage blocks.The multiple snapshots of a storage element are not independent copies,each consuming disk space; therefore, creation of a snapshot on the filesystem is instantaneous, since no entity data needs to be copied. toRead-only accessibility denotes that a snapshot cannot be modifiedbecause it is closely coupled to a single writable image in the activefile system. The closely coupled association between a file in theactive file system and the same file in a snapshot obviates the use ofmultiple “same” files. In the example of a WAFL file system, snapshotsare described in TR3002 File System Design for a NFS File ServerAppliance by David Hitz et is al., published by Network Appliance, Inc.and in U.S. Pat. No. 5,819,292 entitled. Method for MaintainingConsistent States of a File System and For Creating User-AccessibleRead-Only Copies of a File System, by David Hitz et al., each of whichis hereby incorporated by reference as though full set forth herein.

Changes to the file system are tightly controlled to maintain the filesystem in a consistent state. The file system progresses from oneself-consistent state to another self-consistent state. The set ofself-consistent blocks on disk that is rooted by the root inode isreferred to as a consistency point (CP). To implement consistencypoints, WAFL always writes new data to unallocated blocks on disk. Itnever overwrites existing data. A new consistency point occurs when thefsinfo block is updated by writing a new root inode for the inode fileinto it. Thus, as long as the root inode is not updated, the state ofthe file system represented on disk does not change.

The present invention also creates snapshots, which are virtualread-only copies of the file system. A snapshot uses no disk space whenit is initially created. It is designed so that many different snapshotscan be created for the same file system. Unlike prior art file systemsthat create a clone by duplicating the entire inode file and all of theindirect blocks, the present invention duplicates only the inode thatdescribes the inode file. Thus, the actual disk space required for asnapshot is only the 128 bytes used to store the duplicated inode. The128 bytes of the present invention required for a snapshot issignificantly less than the many megabytes used for a clone in the priorart.

The present invention prevents new data written to the active filesystem from overwriting “old” data that is part of a snapshot(s). It isnecessary that old data not be overwritten as long as it is part of asnapshot. This is accomplished by using a multi-bit free-block map. Mostprior art file systems use a free block map having a single bit perblock to indicate whether or not a block is allocated. The presentinvention uses a block map having 32-bit entries. A first bit indicateswhether a block is used by the active file system, and 20 remaining bitsare used for up to 20 snapshots, however, some bits of the 31 bits maybe used for other purposes.

The active map denotes a file including a bitmap associated with a freestatus of the active file system. As noted, a logical volume may beassociated with a file system; the term “active file system” refers to aconsistent state of a current file system. The summary map denotes afile including an inclusive logical OR bitmap of all snapmaps. Byexamining the active and summary maps, the file system can determinewhether a block is in use by either the active file system or anysnapshot. The space map denotes a file including an array of numbersthat describe the number of storage blocks used (counts of bits inranges) in a block allocation area. In other words, the space map isessentially a logical OR bitmap between the active and summary maps toprovide a condensed version of available “free block” areas within thevbn space. Examples of snapshot and block allocation data structures,such as the active map, space map and summary map, are described in U.S.Patent Application Publication No. US2002/0083037 A1, titled InstantSnapshot, by Blake Lewis et al. and published on Jun. 27, 2002, nowissued as U.S. Pat. No. 7,454,445 on Nov. 18, 2008, which application ishereby incorporated by reference.

The write anywhere file system includes a write allocator that performswrite allocation of blocks in a logical volume in response to an eventin the file system (e.g., dirtying of the blocks in a file). The writeallocator uses the block allocation data structures to select freeblocks within its vbn space to which to write the dirty blocks. Theselected blocks are generally in the same positions along the disks foreach RAID group (i.e., within a stripe) so as to optimize use of theparity disks, Stripes of positional blocks may vary among other RAIDgroups to, e.g., allow overlapping of parity update operations. Whenwrite allocating, the file system traverses a small portion of each disk(corresponding to a few blocks in depth within each disk) to essentially“lay down” a plurality of stripes per RAID group. In particular, thefile system chooses vbns that are on the same stripe per RAID groupduring write allocation using the vbn-to-disk, dbn mappings.

When write allocating within the volume, the write allocator typicallyworks down a RAID group, allocating all free blocks within the stripesit passes over. This is efficient from a RAID system point of view inthat more blocks are written per stripe. It is also efficient from afile system point of view in that modifications to block allocationmetadata are concentrated within a relatively small number of blocks.Typically, only a few blocks of metadata are written at the writeallocation point of each disk in the volume. As used herein, the writeallocation point denotes a general location on each disk within the RAIDgroup (e.g., a stripe) where write operations occur.

Write allocation is performed in accordance with a conventional writeallocation procedure using the block allocation bitmap structures toselect free blocks within the vbn space of the logical volume to whichto write the dirty blocks. Specifically, the write allocator examinesthe space map to determine appropriate blocks for writing data on disksat the write allocation point. In addition, the write allocator examinesthe active map to locate free blocks at the write allocation point. Thewrite allocator may also examine snapshotted copies of the active mapsto determine snapshots that may be in the process of being deleted.

According to the conventional write allocation procedure, the writeallocator chooses a vbn for a selected block, sets a bit in the activemap to indicate that the block is in use and increments a correspondingspace map entry which records, in concentrated fashion, where blocks areused. The write allocator then places the chosen vbn into an indirectblock or inode file “parent” of the allocated block. Thereafter, thefile system “frees” the dirty block, effectively returning that block tothe vbn space. To free the dirty block, the file system typicallyexamines the active map, space map and a summary map. The file systemthen clears the bit in the active map corresponding to the freed block,checks the corresponding bit in the summary map to determine if theblock is totally free and, if so, adjusts (decrements) the space map.

The present invention is directed to a technique that extends theconventional write allocation procedure to comport with an extended filesystem layout of a storage system.

SUMMARY OF THE INVENTION

The present invention is directed to a write allocation technique thatextends a conventional write allocation procedure employed by a writeanywhere file system of a is storage system. A write allocator of thefile system implements the extended write allocation technique inresponse to an event in the file system. The extended write allocationtechnique efficiently allocates blocks, and frees blocks, to and from avirtual volume (vvol) of an aggregate. The aggregate is a physicalvolume comprising one or more groups of disks, such as RAID groups,underlying one or more vvols of the storage system. The aggregate hasits own physical volume block number (pvbn) space and maintainsmetadata, such as block allocation “bitmap” structures, within that pvbnspace. Each vvol also has its own virtual volume block number (vvbn)space and maintains metadata, such as block allocation bitmapstructures, within that vvbn space. The inventive technique extendsinput/output (I/O) efficiencies of the conventional write allocationprocedure to comport with an extended file system layout of the storagesystem.

According to the extended write allocation technique, block allocationproceeds in parallel on the vvol and the aggregate when write allocatinga block within the vvol, with the write allocator selecting a pvbn inthe aggregate and a vvbn in the vvol. The write allocator adjusts theblock allocation bitmap structures, such an active map and space map, ofthe aggregate to record the selected pvbn and adjusts similar structuresof the vvol to record the selected vvbn. A virtual volume identifier(vvid) of the vvol and the vvbn are inserted into an owner map of theaggregate at an entry defined by the selected pvbn. The selected pvbn isalso inserted into a container map of the vvol. Finally, an indirectblock or inode file parent of the allocated block is updated with one ormore block pointers to the allocated block. The content of the updateoperation depends on the vvol embodiment. For a “hybrid” vvolembodiment, the selected pvbn is inserted in the indirect block or inodeas a block pointer. However, for a “dual vbn hybrid” vvol embodiment,both the pvbn and vvbn are inserted in the indirect block or inode asblock pointers.

When freeing a block from a vvol, the write allocator acquires the vvbnof the corresponding block. In the dual vbn hybrid embodiment, the writeallocator acquires the vvbn directly from the indirect block or inodefile parent of the freed block. In the hybrid vvol embodiment, however,only the pvbn is available in the indirect block or inode file parent ofthe freed block; accordingly, the write allocator accesses the owner mapof the aggregate in order to acquire the vvbn. Once the vvbn isacquired, the write allocator clears the active map bit entry for thevvbn in the vvol, checks the summary map entry for the vvbn in the vvoland decrements the space map of the vvol if the vvbn is totally free. Ifthe vvbn is totally free, the block may also be “freed” for return tothe aggregate. That is, the pvbn is cleared from the container map (atentry vvbn), the active map entry for the pvbn is cleared in theaggregate, the summary map entry for the pvbn is checked in theaggregate and the space map of the aggregate is decremented, asappropriate.

According to an aspect of the invention, freeing of blocks from a vvolmay be delayed to allow amortization of the cost among many accumulatedupdate operations. In particular, the inventive technique allows thefile system to perform “delayed free” operations from the vvol. Adelayed free operation involves clearing of appropriate block allocationbitmaps in the vvol, while delaying the clearing of the container map ofthe vvol and block allocation bitmaps of the aggregate. When asufficient number of free blocks have been accumulated for the vvol (orportion of the vvol) all of the accumulated blocks may be freed from ablock of the container map at once. A space map style optimization maybe applied to the container map of the vvol to keep track of “rich”areas for delayed free operations to improve the efficiency of theseoperations. When clearing blocks of the vvol from the container map, afurther optimization involves not freeing the blocks in the aggregateimmediately, but rather accumulating them into a delete log file. Thefree blocks may be sorted in the delete log to minimize the number ofI/O operations associated with the allocation maps of the aggregate.

BRIEF DESCRIPTION OF THE DRAWINGS

The above and further advantages of the invention may be betterunderstood by referring to the following description in conjunction withthe accompanying drawings in which like reference numerals indicateidentical or functionally similar elements:

FIG. 1 is a schematic block diagram of an environment including astorage system that may be advantageously used with the presentinvention;

FIG. 2 is a schematic block diagram of a storage operating system thatmay be advantageously used with the present invention;

FIG. 3 is a schematic block diagram of an inode that may beadvantageously used with the present invention;

FIG. 4 is a schematic block diagram of a buffer tree of a file that maybe advantageously used with the present invention;

FIG. 5 is a schematic block diagram of an embodiment of an aggregatethat may be advantageously used with the present invention;

FIG. 6 is a schematic block diagram of an on-disk representation of anaggregate;

FIG. 7 is a functional block diagram of a write allocator configured toimplement an extended write allocation technique of the presentinvention;

FIG. 8 is a schematic block diagram of a partial buffer tree of a filethat may be advantageously used with the present invention;

FIG. 9 is a schematic block diagram of a container file that may beadvantageously used with the present invention;

FIG. 10 is a schematic block diagram of a partial buffer tree of a filewithin a virtual volume (vvol) of the aggregate that may beadvantageously used with the present invent on;

FIG. 11 is a schematic block diagram of an owner map that may beadvantageously used with the present invention;

FIG. 12 is a flowchart illustrating a sequence of steps directed toallocating a block within a vvol in accordance with the extended writeallocation technique of the present invention; and

FIG. 13 is a flowchart illustrating a sequence of steps directed tofreeing a block in accordance with the extended write allocationtechnique of the present invention.

DETAILED DESCRIPTION OF THE ILLUSTRATIVE EMBODIMENTS

FIG. 1 is a schematic block diagram of an environment 100 including astorage is system 120 that may be advantageously used with the presentinvention. The storage system is a computer that provides storageservice relating to the organization of information on storage devices,such as disks 130 of a disk array 160. The storage system 120 comprisesa processor 122, a memory 124, a network adapter 126 and a storageadapter 128 interconnected by a system bus 125. The storage system 120also includes a storage operating system 200 that preferably implementsa high-level module, such as a file system, to logically organize theinformation as a hierarchical structure of directories, files andspecial types of files called virtual disks (hereinafter “blocks”) onthe disks.

In the illustrative embodiment, the memory 124 comprises storagelocations that are addressable by the processor and adapters for storingsoftware program code. A portion of the memory may be further organizedas a “buffer cache” 170 for storing data structures associated with thepresent invention. The processor and adapters may, in turn, compriseprocessing elements and/or logic circuitry configured to execute thesoftware code and manipulate the data structures. Storage operatingsystem 200, portions of which are typically resident in memory andexecuted by the processing elements, functionally organizes the system120 by, inter alia, invoking storage operations executed by the storagesystem. It will be apparent to those skilled in the art that otherprocessing and memory means, including various computer readable media,may be used for storing and executing program instructions pertaining tothe inventive technique described herein.

The network adapter 126 comprises the mechanical, electrical andsignaling circuitry needed to connect the storage system 120 to a client110 over a computer network 140, which may comprise a point-to-pointconnection or a shared medium, such as a local area network.Illustratively, the computer network 140 may be embodied as an Ethernetto network or a Fibre Channel (FC) network. The client 110 maycommunicate with the storage system over network 140 by exchangingdiscrete frames or packets of data according to pre-defined protocols,such as the Transmission Control Protocol/Internet Protocol (TCP/IP).

The client 110 may be a general-purpose computer configured to executeapplications 112. Moreover, the client 110 may interact with the storagesystem 120 in accordance with a client/server model of informationdelivery. That is, the client may request the services of the storagesystem, and the system may return the results of the services requestedby the client, by exchanging packets 150 over the network 140. Theclients may issue packets including file-based access protocols, such asthe Common Internet File System (CIFS) protocol or Network File System(NFS) protocol, over TCP/IP when accessing information in the form offiles and directories. Alternatively, the client may issue packetsincluding block-based access protocols, such as the Small ComputerSystems Interface (SCSI) protocol encapsulated over TCP (iSCSI) and SCSIencapsulated over Fibre Channel (FCP), when accessing information in theform of blocks.

The storage adapter 128 cooperates with the storage operating system 200executing on the system 120 to access information requested by a user(or client). The information may be stored on any type of attached arrayof writable storage device media such as video tape, optical, DVD,magnetic tape, bubble memory, electronic random access memory,micro-electro mechanical and any other similar media adapted to storeinformation, including data and parity information. However, asillustratively described herein, the information is preferably stored onthe disks 130, such as HDD and/or DASD, of array 160. The storageadapter includes input/output (I/O) interface circuitry that couples tothe disks over an I/O interconnect arrangement, such as a conventionalhigh-performance, PC serial link topology.

Storage of information on array 160 is preferably implemented as one ormore storage “volumes” that comprise a collection of physical storagedisks 130 cooperating to define an overall logical arrangement of volumeblock number (vbn) space on the volume(s). Each logical volume isgenerally, although not necessarily, associated with its own filesystem. The disks within a logical volume/file system are typicallyorganized as one or more groups, wherein each group may be operated as aRedundant Array of Independent (or Inexpensive) Disks (RAID). Most RAIDimplementations, such as a RAID-4 level implementation, enhance thereliability/integrity of data storage through the redundant writing ofdata “stripes” across a given number of physical disks in the RAIDgroup, and the appropriate storing of parity information with respect tothe striped data. An illustrative example of a RAID implementation is aRAID-4 level implementation, although it should be understood that othertypes and levels of RAID implementations may be used in accordance withthe inventive principles described herein.

To facilitate access to the disks 130, the storage operating system 200implements a write-anywhere file system that cooperates withvirtualization modules to “virtualize” the storage space provided bydisks 130. The file system logically organizes the information as ahierarchical structure of named directories and files on the disks. Each“on-disk” file may be implemented as set of disk blocks configured tostore information, such as data, whereas the directory may beimplemented as a specially formatted file in which names and links toother files and directories are stored. The virtualization modules allowthe file system to further logically organize information as ahierarchical structure of blocks on the disks that are exported as namedlogical unit numbers (luns).

In the illustrative embodiment, the storage operating system ispreferably the NetApp® Data ONTAPT™ operating system available fromNetwork Appliance, Inc., Sunnyvale, Calif. that implements a WriteAnywhere File Layout (WAFL™) file system. However, it is expresslycontemplated that any appropriate storage operating system may beenhanced for use in accordance with the inventive principles describedherein. As such, where the term “WAFL” is employed, it should be takenbroadly to refer to any storage operating system that is otherwiseadaptable to the teachings of this invention.

FIG. 2 is a schematic block diagram of the storage operating system 200that may be advantageously used with the present invention. The storageoperating system comprises a series of software layers organized to forman integrated network protocol stack or, more generally, amulti-protocol engine that provides data paths for clients to access toinformation stored on the storage system using block and file accessprotocols. The protocol stack includes a media access layer 210 ofnetwork drivers (e.g., gigabit Ethernet drivers) that interfaces tonetwork protocol layers, such as the IP layer 212 and its supportingtransport mechanisms, the TCP layer 214 and the User Datagram Protocol(UDP) layer 216. A file system protocol layer provides multi-protocolfile access and, to that end, includes support for the Direct AccessFile System (DAFS) protocol 218, the NFS protocol 220, the CIFS protocol222 and the Hypertext Transfer Protocol (HTTP) protocol 224. A VI layer226 implements the VI architecture to provide direct access transport(DAT) capabilities, such as RDMA, as required by the DAFS protocol 218.

An iSCSI driver layer 228 provides block protocol access over the TCP/IPnetwork protocol layers, while a FC driver layer 230 receives andtransmits block access requests and responses to and from the storagesystem. The FC and iSCSI drivers provide FC-specific and iSCSI-specificaccess control to the blocks and, thus, manage exports of luns to eitheriSCSI or FCP or, alternatively, to both iSCSI and FCP when accessing theblocks on the storage system. In addition, the storage operating systemincludes a storage module embodied as a RAID system 240 that manages thestorage and retrieval of information to and from the volumes/disks inaccordance with I/O operations, and a disk driver system 250 thatimplements a disk access protocol such as, e.g., the SCSI protocol.

Bridging the disk software layers with the integrated network protocolstack layers is a virtualization system that is implemented by a filesystem 280 interacting with virtualization modules illustrativelyembodied as, e.g., vdisk module 290 and SCSI target module 270. Thevdisk module 290 is layered on the file system 280 to enable access byadministrative interfaces, such as a user interface (UI) 275, inresponse to a user (system administrator) issuing commands to thestorage system. The SCSI target module 270 is disposed between the FCand iSCSI drivers 228, 230 and the file system 280 to provide atranslation layer of the virtualization system between the block (lun)space and the file system space, where luns are represented as blocks.The UI 275 is disposed over the storage operating system in a mannerthat enables administrative or user access to the various layers andsystems.

The file system is illustratively a message-based system that provideslogical volume management capabilities for use in access to theinformation stored on the storage devices, such as disks. That is, inaddition to providing file system semantics, the file system 280provides functions normally associated with a volume manager. Thesefunctions include (i) aggregation of the disks, (ii) aggregation ofstorage bandwidth of the is disks, and (iii) reliability guarantees,such as mirroring and/or parity (RAID). The file system 280illustratively implements the WAFL file system (hereinafter generallythe “write-anywhere file system”) having an on-disk formatrepresentation that is block-based using, e.g., 4 kilobyte (kB) blocksand using index nodes (“inodes”) to identify files and file attributes(such as creation time, access permissions, size and block location).The file system uses files to store metadata describing the layout ofits file system; these metadata files include, among others, an inodefile. A file handle, i.e., an identifier that includes an inode number,is used to retrieve an inode from disk.

Broadly stated, all inodes of the write-anywhere file system areorganized into the inode file. A file system (FS) info block specifiesthe layout of information in the file system and includes an inode of afile that includes all other inodes of the file system. Each logicalvolume (file system) has an FS info block that is preferably stored at afixed location within, e.g., a RAID group. The inode of the root FS infoblock may directly reference (point to) blocks of the inode file or mayreference indirect blocks of the inode file that, in turn, referencedirect blocks of the inode file. Within each direct block of the inodefile are embedded inodes, each of which may reference indirect blocksthat, in turn, reference data blocks of a file.

Operationally, a request from the client 110 is forwarded as a packet150 over the computer network 140 and onto the storage system 120 whereit is received at the network adapter 126. A network driver (of layer210 or layer 230) processes the packet and, if appropriate, passes it onto a network protocol and file access layer for additional processingprior to forwarding to the write-anywhere file system 280. Here, thefile system generates operations to load (retrieve) the requested datafrom disk 130 if it is not resident “in core”, i.e., in the buffer cache170. If the information is not in the cache, the file system 280 indexesinto the inode file using the inode number to access an appropriateentry and retrieve a logical vbn. The file system then passes a messagestructure including the logical vbn to the RAID system 240; the logicalvbn is mapped to a disk identifier and disk block number (disk,dbn) andsent to an appropriate driver (e.g., SCSI) of the disk driver system250. The disk driver accesses the dbn from the specified disk 130 andloads the requested data block(s) in buffer cache 170 for processing bythe storage system. Upon completion of the request, the storage system(and operating system) returns a reply to the client 110 over thenetwork 140.

It should be noted that the software “path” through the storageoperating system layers described above needed to perform data storageaccess for the client request received at the storage system mayalternatively be implemented in hardware. That is, in an alternateembodiment of the invention, a storage access request data path may beimplemented as logic circuitry embodied within a field programmable gatearray (FPGA) or an application specific integrated circuit (ASIC). Thistype of hardware implementation increases the performance of the storageservice provided by storage system 120 in response to a request issuedby client 110. Moreover, in another alternate embodiment of theinvention, the processing elements of adapters 126, 128 may beconfigured to offload some or all of the packet processing and storageaccess operations, respectively, from processor 122, to thereby increasethe performance of the storage service provided by the system. It isexpressly contemplated that the various processes, architectures andprocedures described herein can be implemented in hardware, firmware orsoftware.

As used herein, the term “storage operating system” generally refers tothe computer-executable code operable to perform a storage function in astorage system, e.g., that manages data access and may, in the case of afile server, implement file system semantics. In this sense, the ONTAPsoftware is an example of such a storage operating system implemented asa microkernel and including the WAFL layer to implement the WAFL filesystem semantics and manage data access. The storage operating systemcan also be implemented as an application program operating over ageneral-purpose operating system, such as UNIX® or Windows NT®, or as ageneral-purpose operating system with configurable functionality, whichis configured for storage applications as described herein.

In addition, it will be understood to those skilled in the art that theinventive technique described herein may apply to any type ofspecial-purpose (e.g., file server, filer or multi-protocol storageappliance) or general-purpose computer, including a standalone computeror portion thereof, embodied as or including a storage system 120. Anexample of a multi-protocol storage appliance that may be advantageouslyused with the present invention is described in U.S. patent applicationSer. No. 10/215,917 titled, Multi-Protocol Storage Appliance thatprovides Integrated Support for File and Block Access Protocols, filedon Aug. 9, 2002, now issued as U.S. Pat. No. 7,873,700 on Jan. 18, 2011.Moreover, the teachings of this invention can be adapted to a variety ofstorage system architectures including, but not limited to, anetwork-attached storage environment, a storage area network and diskassembly directly-attached to a client or host computer. The term“storage system” should therefore be taken broadly to include sucharrangements in addition to any subsystems configured to perform astorage function and associated with other equipment or systems.

In the illustrative embodiment, a file is represented in thewrite-anywhere file system as an inode data structure adapted forstorage on the disks 130. FIG. 3 is a schematic block diagram of aninode 300, which preferably includes a metadata section 310 and a datasection 350. The information stored in the metadata section 310 of eachinode 300 describes the file and, as such, includes the type (e.g.,regular, directory, virtual disk) 312 of file, the size 314 of the file,time stamps (e.g., access and/or modification) 316 for the file andownership, i.e., user identifier (UID 318) and group ID (GID 320), ofthe file. The contents of the data section 350 of each inode, however,may be interpreted differently depending upon the type of file (inode)defined within the type field 312. For example, the data section 350 ofa directory inode contains metadata controlled by the file system,whereas the data section of a regular inode contains file system data.In this latter case, the data section 350 includes a representation ofthe data associated with the file.

Specifically, the data section 350 of a regular on-disk inode mayinclude file system data or pointers, the latter referencing 4 kB datablocks on disk used to store the file system data. Each pointer ispreferably a logical vbn to facilitate efficiency among the file systemand the RAID system 240 when accessing the data on disks. Given therestricted size (e.g., 128 bytes) of the inode, file system data havinga size that is less than is or equal to 64 bytes is represented, in itsentirety, within the data section of that inode. However, if the filesystem data is greater than 64 bytes but less than or equal to 64 kB,then the data section of the inode (e.g., a first level inode) comprisesup to 16 pointers, each of which references a 4 kB block of data on thedisk.

Moreover, if the size of the data is greater than 64 kB but less than orequal to 64 megabytes (MB), then each pointer in the data section 350 ofthe inode (e.g., a second level inode) references an indirect block(e.g., a first level block) that contains 1024 pointers, each of whichreferences a 4 kB data block on disk. For file system data having a sizegreater than 64 MB, each pointer in the data section 350 of the inode(e.g., a third level inode) references a double-indirect block (e.g., asecond level block) that contains 1024 pointers, each referencing anindirect (e.g., a first level) block. The indirect block, in turn, thatcontains 1024 pointers, each of which references a 4 kB data block ondisk. When accessing a file, each block of the file may be loaded fromdisk 130 into the buffer cache 170.

When an on-disk inode (or block) is loaded from disk 130 into buffercache 170, its corresponding in core structure embeds the on-diskstructure. For example, the dotted line surrounding the inode 300 (FIG.3) indicates the in core representation of the on-disk inode structure.The in core structure is a block of memory that stores the on-diskstructure plus additional information needed to manage data in thememory (but not on disk). The additional information may include, e.g.,a “dirty” bit 360. After data in the inode (or block) isupdated/modified as instructed by, e.g., a write operation, the modifieddata is marked “dirty” using the dirty bit 360 so that the inode (block)can be subsequently “flushed” (stored) to disk. The in core and on-diskformat structures of the WAFL file to system, including the inodes andinode file, are disclosed and described in the previously incorporatedU.S. Pat. No. 5,819,292 titled Method for Maintaining Consistent Statesof a File System and for Creating User-Accessible Read-Only Copies of aFile System by David Hitz et al., issued on Oct. 6, 1998.

FIG. 4 is a schematic block diagram of a buffer tree of a file that maybe advantageously used with the present invention. The buffer tree is aninternal representation of blocks for a file (e.g., file A 400) loadedinto the buffer cache 170 and maintained by the write-anywhere filesystem 280. A root (top-level) inode 402, such as an embedded inode,references indirect (e.g., level 1) blocks 404. The indirect blocks (andinode) contain pointers 405 that ultimately reference data blocks 406used to store the actual data of file A. That is, the data of file A 400are contained in data blocks and the locations of these blocks arestored in the indirect blocks of the file. Each level 1 indirect block404 may contain pointers to as many as 1024 data blocks. According tothe “write anywhere” nature of the file system, these blocks may belocated anywhere on the disks 130.

The present invention is directed to a write allocation technique thatextends a conventional write allocation procedure employed by a writeanywhere file system of a storage system. A write allocator of the filesystem implements the extended write allocation technique in response toan event in the file system (e.g., writing/updating of a file). Theextended write allocation technique efficiently allocates blocks, andfrees blocks, to and from a virtual volume (vvol) of an aggregate. Theaggregate is a physical volume comprising one or more groups of disks,such as RAID groups, underlying one or more vvols of the storage system.The aggregate has its own physical volume block number (pvbn) space andmaintains metadata, such as block allocation bitmap structures, withinthat pvbn space. Each vvol also has its own virtual volume block number(vvbn) space and maintains metadata, such as block allocation bitmapstructures, within that vvbn space. The inventive technique extends I/Oefficiencies of the conventional write allocation procedure to comportwith an extended file system layout of the storage system.

In the illustrative embodiment, pvbns are used as block pointers withinbuffer trees of files (such as file 400) stored in a vvol. By utilizingpbvns (instead of vvbns) as block pointers within the buffer trees, theextended file system layout facilitates efficient read performance onread paths of those files. This illustrative “hybrid” vvol embodimentinvolves the insertion of only the pvbn in the parent indirect block(e.g., inode or volinfo block). Use of pvbns avoids latency associatedwith translations from vvbns-to-is pvbns, e.g., when servicing filesystem (such as NFS, CIFS) requests. On a read path of a logical volume,a “logical” volume (vol) info block has a pointer that references anfsinfo block that, in turn, “points to” an inode file and itscorresponding buffer tree. The read path on a vvol is generally thesame, following pvbns (instead of vvbns) to find appropriate locationsof blocks; in this context, the read path (and corresponding readperformante) of a vvol is substantially similar to that of a physicalvolume. Translation from pvbn-to-disk, dbn occurs at the filesystem/RAID system boundary of the storage operating system 200.

In an alternate “dual vbn hybrid” vvol embodiment, both the pvbn andvvbn are inserted in the parent indirect (e.g., level 1) blocks in abuffer tree of a file. Here, the use of pvbns as block pointers in theindirect blocks provides efficiencies in the read paths, while the useof vvbn block pointers provides efficient access to required metadata,such as per-volume block allocation information. That is, when freeing ablock of a file, the parent indirect block in the file contains readilyavailable vvbn block pointers, which avoids the latency associated withaccessing an owner map (described herein) to perform pvbn-to-vvbntranslations; yet, on the read path, the pvbn is available. Adisadvantage of this dual vbn variant is the increased size ofindirection data (metadata) stored in each file.

FIG. 5 is a schematic block diagram of an embodiment of an aggregate 500that may be advantageously used with the present invention. Luns(blocks) 502, directories 504, qtrees 506 and files 508 may be containedwithin vvols 510 that, in turn, are contained within the aggregate 500.The aggregate 500 is illustratively layered on top of the RAID system,which is represented by at least one RAID plex 550 (depending uponwhether the storage configuration is mirrored), wherein each plex 550comprises at least to one RAID group 560. Each RAID group furthercomprises a plurality of disks 530, e.g., one or more data (D) disks andat least one (P) parity disk.

Whereas the aggregate 500 is analogous to a physical volume of aconventional storage system, a vvol is analogous to a file within thatphysical volume. That is, the aggregate 500 may include one or morefiles, wherein each file contains a vvol 510 and is wherein the sum ofthe storage space consumed by the vvols is physically smaller than (orequal to) the size of the overall physical volume. The aggregateutilizes a “physical” pvbn space that defines a storage space of blocksprovided by the disks of the physical volume, while each embedded vvol(within a file) utilizes a “logical” vvbn space to organize thoseblocks, e.g., as files. Each vvbn space is an independent set of numbersthat corresponds to locations within the file, which locations are thentranslated to dbns on disks. Since the vvol 510 is also a logicalvolume, it has its own block allocation structures (e.g., active, spaceand summary maps) in its vvbn space.

FIG. 6 is a schematic block diagram of an on-disk representation of anaggregate 600. The storage operating system 200, e.g., the RAID system240, assembles a physical volume of pvbns to create the aggregate 600,with pvbns 1 and 2 comprising a “physical” volinfo block 602 for theaggregate. The volinfo block 602 contains block pointers to fsinfoblocks 604, each of which may represent a snapshot of the aggregate.Each fsinfo block 604 includes a block pointer to an inode file 606 thatcontains inodes of a plurality of files, including an owner map 1100, anactive map 612, a summary map 614 and a space map 616, as well as otherspecial metadata files. The inode file 606 further includes a rootdirectory 620 and a “hidden” metadata root directory 630, the latter ofwhich includes a namespace having files related to a vvol in which userscannot “see” the files. The hidden metadata root directory also includesa WAFL/fsid/directory structure, as described herein, which contains afilesystem file 640 and storage label file 690. Note that root directory620 in the aggregate is empty; all files related to the aggregate areorganized within the hidden metadata root directory 630.

The filesystem file 640 includes block pointers that reference variousfile systems embodied as vvols 650. The aggregate 600 maintains thesevvols 650 at special reserved inode numbers. Each vvol 650 also hasspecial reserved inode numbers within its vvol space that are used for,among other things, the block allocation bitmap structures. As noted,the block allocation bitmap structures, e.g., active map 662, summarymap 664 and space map 666, are located in each vvol.

Specifically, each vvol 650 has the same inode file structure/content asthe aggregate, with the exception that there is no owner map and noWAFL/fsid/filesystemfile, storage label file directory structure in ahidden metadata root directory 680. To that end, each vvol 650 has avolinfo block 652 that points to one or more fsinfo blocks 654, each ofwhich may represent a snapshot of the vvol. Each fsinfo block, in turn,points to an inode file 660 that, as noted, has the same inodestructure/content as the aggregate with the exceptions noted above. Eachvvol 650 has its own inode file 660 and distinct inode space withcorresponding inode numbers, as well as its own root (fsid) directory670 and subdirectories of files that can be exported separately fromother vvols.

The storage label file 690 contained within the hidden metadata rootdirectory 630 of the aggregate is a small file that functions as ananalog to a conventional raid label. A raid label includes “physical”information about the storage system, such as the volume name; thatinformation is loaded into the storage label file 690. Illustratively,the storage label file 690 includes the name 692 of the associated vvol650, the online/offline status 694 of the vvol, and other identity andstate information 696 of the associated vvol (whether it is in theprocess of being created or destroyed).

According to an aspect of the extended write allocation technique, blockallocation proceeds (is performed) in parallel on the vvol and theaggregate when write allocating a block within the vvol, with the writeallocator independently selecting a pvbn in the aggregate and a vvbn inthe vvol. In essence, the write allocator 700 moves down physical disksof a RAID group and a logical disk of each vvol in parallel, selecting apvbn and a vvbn for each write allocated block. FIG. 7 is a functionalblock diagram of a write allocator 700 configured to implement theextended write allocation technique of the present invention. The writeallocator maintains a pvbn space 720 and vvbn space 730 in accordancewith the inventive technique. The write allocator selects a pvbn for thefile by selecting a disk 715 of a RAID group 725 that is “farthest back”(from the last stripe), scanning that disk a certain depth and selectingall free blocks. The write allocator then moves to a next disk in theRAID group and performs the same procedure.

When selecting a vvbn, the file system views the vvbn space of a vvol asa large “logical” disk 735, since the vvbn space 730 does not relate tothe physical properties of is the disks within RAID group 725. The filesystem references a write allocation point 740 in the logical disk 735to select a vvbn from the vvbn space 730 of the vvol. For each disk of avvol, the file system constructs write allocations blocks (buffers) thatare used at the write allocation point 740. By treating the vvbn spaceas a large logical disk, only one write allocation point is neededwithin the vvol, thereby limiting the number of write allocation buffersthat need to be written.

As described further herein, the write allocator adjusts the blockallocation bitmap structures, such the active map 612 and space map 616,of the aggregate to record the selected pvbn and adjusts the active andspace map structures 662, 666 of the vvol to record the selected vvbn. Avirtual volume identifier (vvid) and the vvbn are inserted into theowner map 1100 of the aggregate at an entry defined by the pvbn torecord use of the pvbn. It should be noted that in the dual vbn hybridembodiment, there is no requirement for the owner map and, thus, updatesof the owner map for the vvid and vvbn can be avoided. That pvbn is alsoinserted into a container map 950 of the vvol. Finally, an indirectblock or inode file parent of the allocated block is updated with ablock pointer to the allocated block. The content of the updateoperation depends on the vvol embodiment. For a hybrid vvol embodiment,the pvbn is inserted in the parent indirect block (e.g., inode orvolinfo block). However, for a dual vbn hybrid vvol embodiment, both thepvbn and vvbn are inserted in the indirect block.

Specifically, when write allocating a block in a file of the aggregate(e.g., a container file, a storage label file or active/summary/ownermap files), only the aggregate's bitmaps and buffers are used andaffected. The write allocator 700 selects a pvbn, marks thecorresponding bits in the active map 612 of the aggregate as “in use”and places the pvbn into a parent (indirect block or inode) of the blockbeing write allocated. Direct allocation of the container file occurswhen write allocating the volinfo block 652 of the vvol; such directallocation is analogous to direct write operations to the RAID system.When write allocating a block of a vvol, however, the write allocatorselects (i) a pvbn in the aggregate (a “physical” block on disk) forstoring data of the allocated block and (ii) a vvbn (a “logical” block)in the vvol for enabling logical operations, such as a snapshot, on thedata of the block.

FIG. 8 is a schematic block diagram of a partial buffer tree of a file800 that may be advantageously used with the present invention. Assumepvbn 3000 is selected for a write allocated (level 0) block 804 of thefile 800. Assume also that vvbn 5000 is selected as the logical pointerassociated with the physical pointer pvbn 3000 for the new writeallocated block 804. A next write allocated (level 0) block 806 in thefile may be assigned pvbn 3001 and vvbn 5002. For the illustrativehybrid vvol embodiment, the write allocator 700 inserts the pvbns intothe parent blocks of the write allocated blocks, whereas for thealternate dual vbn hybrid vvol embodiment, the write allocator insertsboth the pvbns and vvbns into the parent blocks. Note that a parentblock may comprise indirect block of a file, an inode 802 of the file,or a volinfo block of a write allocated fsinfo block of, e.g., a vvol.

FIG. 9 is a schematic block diagram illustrating a vvol embodied ascontainer file 900. The container file is a file in the aggregate havinglevel 0 (data) blocks that comprise all blocks used to hold data in avvol; that is, the level 0 data blocks of the container file contain allblocks used by a vvol. Level 1 (and higher) indirect blocks of thecontainer file reside in the aggregate and, as such, are consideredaggregate blocks. The container file is an internal (to the aggregate)feature that supports a vvol; illustratively, there is one containerfile per vvol. The container file is a hidden file (not accessible to auser) in the aggregate that holds every block in use by the vvol. Whenoperating in a vvol, vvbn identifies a file block number (fbn) locationwithin the file and the file system uses the indirect blocks of thehidden container file to translate the fbn into a physical vbn (pvbn)location within the physical volume, which block can then be retrievedfrom disk. As noted, the aggregate includes the illustrative hiddenmetadata root directory 630 that to contains subdirectories of vvols:

-   -   WAFL/fsid/filesystem file, storage label file

A “physical” file system (WAFL) directory includes a subdirectory foreach vvol in the aggregate, with the name of subdirectory being a filesystem identifier (fsid) of the vvol. As further noted, each fsidsubdirectory (vvol) has at least two files, a filesystem file 640 and astorage label file 690. The storage label file 690 is illustratively a4kB file that contains metadata similar to that stored in a conventionalraid label. In other words, the storage label file is the analog of araid label and, as such, contains information about the state of thevvol such as, e.g., the name of the vvol, a universal unique identifier(uuid) and fsid of the vvol, whether it is online, being created orbeing destroyed, etc.

The filesystem file 640 is a large sparse file that contains all blocksowned by a vvol and, as such, is referred to as the container file forthe vvol. The container file 900 is assigned a new type and has an inode902 that is assigned an inode number equal to a vvid of the vvol, e.g.,container file 900 has an inode number 113. The container file isessentially one large, sparse virtual disk and, since it contains allblocks owned by its vvol, a block with vvbn X in the vvol can be foundat fbn X in the container file. For example, vvbn 5005 in a vvol can befound at fbn 5005 in its container file 900.

FIG. 10 is a schematic block diagram of a partial buffer tree of a file1000 within a vvol of the aggregate that may be advantageously used withthe present invention. The buffer tree includes a top-level inode 1002that has a block pointer to a level 1 indirect block (L1,1) 1004 which,in turn, has block pointers that reference level 0 blocks (L0,1) 1006and (L0,2) 1008. Note that in the hybrid vvol embodiment, the blockpointers comprise pvbns (as illustrated), whereas in the dual vbn hybridvvol embodiment the block pointers comprise pvbn,vvbn pairs. All of theblocks of the buffer tree, including the level 1 (L1) and level 0 (L0)blocks of the file 1000, as well as all inode file blocks, fsinfo blocksand volinfo blocks in a vvol, are located within level 0 blocks of thecorresponding container file 900. For example, the level 0 blocks906-910 of the container file 900 hold (L0,1), (L0,2), and (L1,1),respectively.

Assume that level 0 block 910 of the container file 900 has an fbn 5005and a “parent” indirect (level 1) block 905 of that level 0 block has ablock pointer referencing the level 0 block, wherein the block pointerhas a pvbn 3005. Thus, location fbn 5005 of the container file 900 ispvbn 3005 (on disk). Notably, the block numbers are maintained at thefirst indirect level (level 1) of the container file 900; e.g., tolocate block 5005 in the container file, the file system layer accessesthe 5005^(th) entry at level 1 of the container file and that indirectblock provides the pvbn 3005 for fbn 5005.

In other words, level 1 indirect blocks 904, 905 of the container file900 contain the pvbns for blocks in the file and, thus, provides a“forward” mapping of vvbns of a vvol to pvbns of the aggregate. Thelevel 1 indirect blocks of the container file 900 are thus configured asa container map 950 for the vvol; there is preferably one container map950 per vvol. Specifically, the container map provides block pointersfrom fbn locations within the container file to pvbn locations on disk.Furthermore, there is a one-to-one correspondence between fbn locationsin the container file and vvbn locations in a vvol; this allowsapplications that need to access the vvol to find blocks on disk via thevvbn space. Accordingly, the write allocator inserts pvbn 3000 at blocklocation (vvbn) 5000 of the container map 950 for the vvol and pvbn 3001at block location (vvbn) 5002 of that map.

Each vvol has its own vvbn space that contains its own version of allfile system metadata files, including block allocation (bitmap)structures that are sized to that space. As noted, the indirect blocksof files within a vvol illustratively contain pvbns in the underlyingaggregate rather than (or in addition to) vvbns. For example, whenupdating/modifying data (i.e., “dirtying”) of an “old” block in a fileduring write allocation, the file system selects a new block and freesthe old block, which involves clearing bits of the block allocationbitmaps for the old block in the logical volume's vbn (now pvbn) space.In essence, the file system 280 only knows that a particular physicalblock (pvbn) has been dirtied. However, freeing blocks within the vvolrequires use of a vvbn to clear the appropriate bits in thevvbn-oriented block allocation files. Therefore, in the absence of avvbn, a “backward” mapping (pvbn-to-vvbn) mechanism is needed at theaggregate to level.

In the illustrative embodiment, mapping metadata provides a backwardmapping between each pvbn in the aggregate to (i) a vvid that “owns” thepvbn and (ii) the vvbn of the vvol in which the pvbn is located. Thebackward mapping metadata is preferably sized to the pvbn space of theaggregate; this does not present a scalability concern, since themapping metadata for each of vvol can be interleaved into a single file,referred to as an owner map 1100, in the aggregate. FIG. 11 is aschematic block diagram of an owner map 1100 that may be advantageouslyused with the present invention. The owner map 1100 may be embodied as adata structure having a plurality of entries 1110; there is preferablyone entry 1110 for each block in the aggregate.

In the illustrative embodiment, each entry 1110 has a 4-byte vvid and a4-byte vvbn, and is indexed by a pvbn. That is, for a given block in theaggregate, the owner entry 1110 indicates which vvol owns the block andwhich pvbn it maps to in the vvbn space. As such, the write allocatorinserts (vvid 113, vvbn 5000) at entry pvbvn 3000 of the owner map 1100.In addition, the write allocator inserts (vvid 113, vvbn 5002) at entrypvbn 3001 of the owner map 1100. Thus when indexing into the owner map1100 at pvbn 3000, the file system 280 accesses a vvol having an inode113 (which is container file 900) and then accesses block location 5000within that file. Each entry 1110 of the owner map 1100 is only validfor blocks that are in use; therefore, updates to the owner map areoptimized to occur at a write allocation point. In general, a vvol onlyowns those blocks used in the contained file system. There may besituations where the vvol owns blocks the contained file system is notusing. Allocated blocks that are not owned by any vvol illustrativelyhave owner map entries (0, 0).

FIG. 12 is a flowchart illustrating a sequence of steps directed toallocating a block within a vvol in accordance with the extended writeallocation technique of the present invention. According to thetechnique, block allocation is preferably performed in parallel on thevvol and the aggregate. The sequence starts at Step 1200 and proceeds toStep 1202 where the write allocator selects a pvbn in the aggregate anda vvbn in the vvol, as described above. In Step 1204, the writeallocator adjusts the block allocation bitmap structures, such activemap 612 and space map 616, of the aggregate to record the selected pvbnand, in Step 1206, adjusts similar bitmap structures 662, 666 of thevvol to record the selected vvbn. In Step 1208, the write allocatorinserts a vivid of the vvol and the vvbn into the owner map 1100 of theaggregate at an entry defined by the pvbn. Note that in the dual vbnhybrid embodiment, there is no requirement for the owner map and, isthus, the insertions to the owner map (Step 1208) may beeliminated/avoided. In Step 1210, the write allocator inserts the pvbninto the container map 950 of the vvol. In Step 1212, the writeallocator updates an indirect block or inode file parent of theallocated block with block pointer(s) to the allocated block, whereinthe content of the update operation depends on the type of vvol.Specifically, in Step 1214, a determination is made as to whether thevvol is a hybrid vvol. If so, the pvbn is inserted in the indirect blockor inode as a block pointer in Step 1216. If not, the vvol is a dual vbnhybrid and, as such, both the pvbn and vvbn are inserted in the indirectblock or inode as block pointers in Step 1218. The sequence then ends atStep 1220.

Another aspect of the present invention involves freeing of a block.When freeing a block of the hybrid vvol embodiment, the applicable vbnis the pvbn of the aggregate. The write allocator 700 locates thecontainer map entry for the block and uses it to find the correspondingvvbn. The write allocator then loads the active, summary and space mapbuffers for both the pvbns and vvbns, and loads the owner map entry. Theallocator 700 clears the active map block of the vvol, checks thesummary map and adjusts the space map if the block is freed. This, inturn, requires clearing of the container entry and the active map in theaggregate, examining of the summary map and adjusting of the space map,if necessary.

Assume block (pvbn 3001, vvbn 5002) of a dual vbn hybrid vvol embodimentis dirtied and is prepared for subsequent write allocation. Whendirtying (overwriting) a block, the file system 280 frees the old blockand writes to a new block. At a next consistency point, the writeallocator selects a new pvbn (e.g., 4001) and a new vvbn (e.g., 6002),as described above. The write allocator frees the dirty block using thecontainer map 950 and owner map 1100, the latter enabling pvbn-to-vvbntranslation.

Broadly stated, the write allocator accesses the owner map 1100 at pvbn3001 to obtain vvid 113 (the inode number of the container file 300) andthe appropriate vvbn 5002 (the fbn location within the container file).The allocator 700 clears bit 5002 in the active map for the vvol andexamines the summary map of the vvol to determine the state of bit 5002.If that bit is also cleared in the summary map, then vvbn block 5002 istotally free in the vvol (not used in any snapshot) and may be releasedfrom the container file 900 and returned to the aggregate. Note that thevvol (container file 900) may choose to keep that block within its vvbnspace instead of returning it to the aggregate. However, if the bit isset in the summary map, block 5002 is still used in at least onesnapshot and the container file “holds on” to that block at the vvollevel.

Assuming vvbn block 5002 is totally free, the write allocator clearsblock vvbn 5002, pvbn 3001 in the container map 950. The allocatoraccesses the level 1 blocks of the container file (the container map950) using the size of the container file (vvol) to compute the levelsof indirection needed in the file. The write allocator also clears thecorresponding bits in the active/summary maps of the aggregate to returnblock pvbn 3001 to the aggregate; otherwise, the allocator could delaythis action. In any event, the write allocator inserts new pvbn 4001into vvbn block 6002 of the container map and loads entry pvbn 4001 with(vvid 113, vvbn 6002) in the owner map.

FIG. 13 is a flowchart illustrating a sequence of steps directed tofreeing a block in accordance with the extended write allocationtechnique of the present invention. The sequence starts at Step 1300 andproceeds to Step 1302 where a determination is made as to whether thevvol is a hybrid vvol. If not, the write allocator acquires the vvbn ofthe freed block directly from the indirect block or inode file parent ofthe freed block in Step 1304. However, if the vvol is a hybrid vvol,only the pvbn is available in the indirect block or inode file parent ofthe freed block; accordingly, the write allocator accesses the owner map1100 of the aggregate to acquire the vvbn in Step 1306. The writeallocator uses the acquired vvbn to clear a bit entry of the vvol activemap 662 for the vvbn in Step 1308 and, in Step 1310, to check theappropriate bit entry of the vvol summary map 664 for the vvbn todetermine whether the vvbn is totally free in the vvol. If the vvbn isnot totally free, e.g., the bit entry is not cleared, (Step 1312), thecontainer file holds on to (retains) that vvbn block at the vvol levelin Step 1314 and the sequence ends at Step 1328.

However, if the vvbn is totally free in the vvol, e.g., the bit entry ofthe vvol summary map is cleared, the block may also be “freed” forreturn to the aggregate. In Step 1316, the write allocator decrementsthe space map 666 of the vvol and, in Step 1318, clears the pvbn of thefreed block from the container map 950 (at entry vvbn of the freedblock) of vvol to thereby free (release) the freed block from the vvol.In Step 1320, the allocator 700 clears the appropriate pvbn bit entry ofthe aggregate active map 612 and, in Step 1322, checks the appropriateentry of the aggregate summary map 614 for the pvbn to determine whetherthe pvbn is totally free. If the pvbn is not totally free, e.g., the bitentry is not cleared, (Step 1324), the sequence ends at Step 1328.However, if the pvbn is totally free, e.g., the bit entry is cleared,the write allocator decrements the aggregate space map 666 in Step 1326and the sequence ends at Step 1328.

In an aspect of the inventive technique, the file system 280 may performa “delayed free” operation from the vvol that essentially delays releaseof a free block from a vvol to the aggregate. In the illustrativeembodiment, the file system decides whether to do a delayed freeoperation when it is preparing to free the block within the vvol.Releasing of freed blocks from a vvol may be delayed to allowamortization of the cost among many accumulated update operations. Thedecision as to whether to release the free block depends on how manydelayed free block operations are pending and how much free space isavailable in the aggregate. The number of delayed free operations fromthe container file is maintained in the storage label file for the vvol.

If the delayed free operation is not performed, the file system freesthe block within the vvol, but leaves the block as owned by the vvolwithin the aggregate. If the delayed free operation is performed, thefile system clears appropriate block allocation bitmaps in the vvol, butdelays clearing of the container map 950 of the vvol and blockallocation bitmaps of the aggregate. When a sufficient number of freeblocks have been accumulated for the vvol (or portion of the vvol) allof the accumulated blocks may be freed from a block of the container mapat once. In general, it is efficient to free all accumulated unusedblocks from a container map block at a time.

A space map style optimization may be applied to the container map 950of the vvol to keep track of “rich” areas for delayed free operations toimprove the efficiency of these operations. The space map styleoptimization indicates how many delayed frees are in different regionsof the vvol. When clearing blocks of a vvol from the container map, afurther optimization involves not freeing the blocks in the aggregateimmediately, but rather accumulating them into a delete log file in theaggregate. When a sufficient number of free blocks are accumulated, theymay be sorted and freed in block order. This optimization minimizes thenumber of I/O operations associated with the container map and blockallocation bitmaps of the aggregate.

In sum, the extended write allocation technique described herein has anumber of novel features. By write allocating at a write allocationpoint of disks within a RAID group, the present technique realizes RAIDefficiencies because blocks are selected within a stripe and all writeblock allocations occur within a few active map blocks. This results ina concentrated area of bits being set in the active map blocks, e.g., aplurality of bits is set in an active map block on each disk. Thus,relatively little metadata is dirtied to perform write allocation. Inparticular, the present technique dirties metadata blocks in a narrowspan of the active map; update operations to the owner map 1100 of theaggregate are also concentrated, according to a feature of the presenttechnique. Note that the owner map is changed only during writeallocation. When freeing a block, a “stale” entry/value is left in theowner map.

While there has been shown and described illustrative embodiments of awrite allocation technique that extends a conventional write allocationprocedure employed by a write anywhere file system of a storage system,it is to be understood that various other adaptations and modificationsmay be made within the spirit and scope of the invention. For example,an alternate embodiment of the invention is directed to “paired volume”write allocation. In the paired volume embodiment, the value of the vvbnis always equal to the value of the pvbn, e.g., pvbn 20 in an indirectblock has a vvbn 20. In other words, a vvol may be maintained so thatits vvbns map to similar pvbns (e.g., vvbn 28383=pvbn 28383). Thisembodiment improves write allocation efficiency, since the file system280 only needs to choose a pvbn for the new block and use that pvbnvalue for the vvbn. The paired volume embodiment thus obviates the needto translate a pvbn to a vvbn using the owner map 1100 since they arethe same value. However, all of the data in a vvol is updated at thewrite allocation point of the disks and the block allocation data forthe vvol must be the same size as the aggregate, impacting snapshotperformance for the vvol.

The paired volume embodiment is particularly useful for upgrade andrevert operations, i.e., allowing reversion back to an old version ofthe file system. To revert, the volinfo block (e.g., block 1 in thecontainer file) is “stomped into” the volinfo block of the aggregate,thereby creating a reverted vvol. An upgrade involves moving pvbns of avvol to the container file and constructing a new aggregate under thatcontainer file. By maintaining pvbn values equal to vvbn values, allindirect blocks in the container file include pvbns and all blockallocation bit maps are in synchronization with the vvbn space sincethat space corresponds directly to the pvbn space. Therefore, the blockallocation bitmaps that specify which blocks are in use are synchronizedto the information stored in the indirect blocks (pvbns).

The foregoing description has been directed to specific embodiments ofthis invention. It will be apparent, however, that other variations andmodifications may be made to the described embodiments, with theattainment of some or all of their advantages. For instance, it isexpressly contemplated that the teachings of this invention can beimplemented as software, including a computer-readable medium havingprogram instructions executing on a computer, hardware, firmware, or acombination thereof. Accordingly this description is to be taken only byway of example and not to otherwise limit the scope of the invention.Therefore, it is the object of the appended claims to cover all suchvariations and modifications as come within the true spirit and scope ofthe to invention.

What is claimed is:
 1. A computer-implemented method, comprising:organizing a plurality of storage devices into an aggregate, where theaggregate is a physical volume organized into a global storage space,and a data block is resident on one of the storage devices of theaggregate; providing a plurality of virtual volumes within theaggregate; allocating the data block to a virtual volume (vvol) of theplurality of virtual volumes, the vvol having a virtual volumeidentification (vvid); selecting a physical volume block number (pvbn)for the data block from a pvbn space of the aggregate; selecting avirtual volume block number (vvbn) for the data block from a vvbn spaceof the vvol to allocate the data block to the vvol; inserting both thepvbn and the vvbn in a parent block of a buffer tree as block pointersto point to the allocated data block on the storage device; maintainingan existing data block after writing to the allocated data block achange directed to data of the existing data block; and inserting thevvid and the vvbn into an owner map of the aggregate at an entry definedby the pvbn.